package com.plpm.config;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

import lombok.Data;

/**
 * IoTDB配置类
 *
 * @author PLPM Team
 * @version 1.0
 */
@Configuration
@EnableAsync
@Data
public class IoTDBConfig {

    @Value("${iotdb.host}")
    private String host;

    @Value("${iotdb.port}")
    private int port;

    @Value("${iotdb.username}")
    private String username;

    @Value("${iotdb.password}")
    private String password;

    @Value("${iotdb.session-pool-size}")
    private int sessionPoolSize;

    @Value("${iotdb.database}")
    private String database;

    /**
     * 异步任务执行器
     */
    @Bean(name = "taskExecutor")
    public Executor taskExecutor() {
        return Executors.newFixedThreadPool(sessionPoolSize);
    }
}
